//
//  RSAEncryptor.h
//  MyLottery
//
//  Created by 项目 on 16/10/19.
//  Copyright © 2016年 项目. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface RSAEncryptor : NSObject


// *** RSA加密
//NSString *encryptStr = [RSAEncryptor encryptString:tempStr publicKey:@"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA3wRUbGGhjLpPDGBh+zjD3izLd4T2csIpjmCdBRQrGb0HmD7RW2ldUD4x3aVf1iERUm+K7a5sLyZAwvC307b3BpLK6k1a58J5DgBvf3yZGqNichEM6syyw8zXmhsc7OdjPLehAMbceo4f9A+JvIkLiQ/C7yz7mn6UdSNvUiW4WQIDAQAB"];


// *** 解密
//[openEncryptorMStr appendFormat:@"%@",[RSAEncryptor decryptString:tempEncryptor privateKey:@"MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMDfBFRsYaGMuk8MYGH7OMPeLMt3hPZywimOYJ0FFCsZvQeYPtFbaV1QPjHdpV/WIRFSb4rtrmwvJkDC8LfTtvcGksrqTVrnwnkOAG9/fJkao2JyEQzqzLLDzNeaGxzs52M8t6EAxtx6jh/0D4m8iQuJD8LvLPuafpR1I29SJbhZAgMBAAECgYEAnAOKyBPHwdtJVeooCPojh+UvjQLITma0AtOF+V4DW339d6hCoC12hKIFPWcSf/yBUTbCvbnXzvEw21AVUk3zAGVQtsKq0qXfzhCsBK8HV4IwlqclptArO+QmzsIu0nv3wHKhMW2NVpDVh256g3j1u//IsK53i4xdK3yQ8omliLUCQQDtQrWPyVQq88crnYm8Se1IybRNNkhCEeyRUxAfzot2P74lOWePz8TVHli1qeUrlJtF/Mo6zNVhbPqzdyGpvZfzAkEA0BrGkkTCkCf/eDmfTp2xnKnG/FLBMVeF/SaEmJftKtQloNxTsCnb70z1u4bGXfHv8rJjoK1Om7tDeSExl/ftgwJAP24zPiK0FtufpuByP12AS5JpWq8leEx0c5HCYM6GaHG4Mxl6v27rj5KSYtbuBs2vCXIA2uGCNo69I5e47zlZ0wJAQwndHhF4e+fmrFwjrbevF8C5kV83TSXczAg0ftOyWzGsTX2sl/tkFlq8boSkMm9V1OESpxgtUo2o1sSSrVn48QJBAKodvkevqoqlIp2o0nevPB6+A1WwRPvmE2djeBpbF73ZaH1LUukLlDKsCdNrGQidB4fuod3l1cJfKN/M3xhGD4k="]];

/**
 *  加密方法
 *
 *  @param str   需要加密的字符串
 *  @param path  '.der'格式的公钥文件路径
 */
+ (NSString *)encryptString:(NSString *)str publicKeyWithContentsOfFile:(NSString *)path;

/**
 *  解密方法
 *
 *  @param str       需要解密的字符串
 *  @param path      '.p12'格式的私钥文件路径
 *  @param password  私钥文件密码
 */
+ (NSString *)decryptString:(NSString *)str privateKeyWithContentsOfFile:(NSString *)path password:(NSString *)password;

/**
 *  加密方法
 *
 *  @param str    需要加密的字符串
 *  @param pubKey 公钥字符串
 */
+ (NSString *)encryptString:(NSString *)str publicKey:(NSString *)pubKey;

/**
 *  解密方法
 *
 *  @param str     需要解密的字符串
 *  @param privKey 私钥字符串
 */
+ (NSString *)decryptString:(NSString *)str;



@end
